﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class LoaiTrongTaiDao
    {
        public IEnumerable<LOAITRONGTAI> LoaiTrongTai()
        {
            DoixeDataContext TV = new DoixeDataContext();
            return TV.LOAITRONGTAIs;
        }
        public int LayMaLoaiTrongTai(string TrongTai)
        {
            DoixeDataContext TV = new DoixeDataContext();
            IEnumerable<LOAITRONGTAI> ttDto;
            ttDto = from tt in TV.LOAITRONGTAIs where tt.LoaiKg == Convert.ToInt32(TrongTai) select tt;
            if (ttDto.Count() == 0)
            {
                return -1;
            }
            return ttDto.Single().MaTrongTai;
        }
    }
}
